package com.Java.train.business.controller;

import com.Java.train.common.response.CommonResp;
import com.Java.train.business.entity.DTO.TrainSeatDTO;
import com.Java.train.business.req.TrainSeatQueryReq;
import com.Java.train.common.response.PageResp;
import com.Java.train.business.entity.TrainSeat;
import com.Java.train.business.service.TrainSeatService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;

/**
* @author luomoxingchen
* @since 2024-09-22
*/
@RestController
@RequestMapping("/admin/train-seat")
public class TrainSeatController {

    @Autowired
    private TrainSeatService trainSeatService;


    @GetMapping("/query-list")
    @ApiOperation("TrainSeat查询全部")
    public CommonResp< PageResp<TrainSeatDTO>> queryList(@Valid TrainSeatQueryReq trainSeatQueryReq){
        PageResp<TrainSeatDTO> list = trainSeatService.queryList(trainSeatQueryReq);
        return new CommonResp<>(list);
    }

    @PostMapping("/save")
    @ApiOperation("TrainSeat修改")
    public CommonResp<Object> update(@Valid @RequestBody TrainSeat trainSeat) {
        return trainSeatService.modify(trainSeat);
    }


    @DeleteMapping(value = "/delete/{ids}")
    @ApiOperation("TrainSeat删除(单个条目)")
    public CommonResp<Object> remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        return trainSeatService.remove(ids);
    }


}
